PI E GAMMA DEG PHI READ WRITE APPEND VERTICAL HORIZONTAL FROMSTART FROMEND FROMHERE INTEL ALPHA SGI MIPS MACINTOSH AMIGA CREATE ATTACH AUTOCLEAR LAYOUT MODELER SCREAMERNET nil true/TRUE false/FALSE X Y ZScripts destined for use under LightWave Modeler have these additional values pre-defined for their use:
GAUSSIAN UNIFORM NORMAL SHARP BUFFERED KNOTS SUBTRACT INTERSECT ADD LENGTHS CORE TUNNEL STENCIL SLICE FLAT SMOOTH METAFORM SET CLEAR VOLUME CONNECT NPEQ NPLT NPGT VOLEXCL VOLINCL SURFACE NVEQ NVLT NVGT CURVE NONPLANAR SELECTED FACE UNSELECTED ABORT START END DETAIL GLOBAL USER RADIAL UNION POLYNDX POLYID POINTNDX POINTIDLightWave 3D Layout scripts have access to their own set of global constant values:
SCENEMODE OBJECTMODE MESH LIGHT CAMERA BONE SCENE POSITION RIGHT UP FORWARD ROTATION SCALING PIVOT WPOSITIONAnd, specific architectures under LightWave 3D Layout also their own specialized values:
SPECIAL LUMINOUS DIFFUSE SPECULAR MIRROR TRANS RAWRED RAWGREEN RAWBLUE SHADING SHADOW GEOMETRY DEPTH RED GREEN BLUE ALPHA
NORMAL COLOR LUMINOUS DIFFUSE SPECULAR MIRROR TRANSPARENT ETA ROUGHNESS RAYTRACE
WORLD LOCAL
NONE PREVIEW RENDERFor more information on the uses of the Modeler-specific constants, please refer to the later sections of this User's Guide that document LScript's Modeler-specific commands.
For information on the uses of the Layout-specific constants, please refer to the sections of this User's Guide that document LScript's Layout-specific commands.
You might invoke this function in the following manner:
... editbegin(); pnt1 = pointinfo(points[1]); pnt2 = pointinfo(points[2]); editend(); info(angle(pnt1,pnt2,X), // return angle in the YZ plane " degrees"); ...
You might invoke this function in the following manner:
... angle = 180; // 180 degrees varSquare = sqrt(angle); // calc square root of angle ...
An example of its usage might be:
... v1 = exp(27.5); ...
An example of its usage might be:
... v1 = log(347.495); ...
The functions sinh(), tanh(), and cosh() calculate the hyperbolic values of their respective functions.
An example of their usage might be:
... sin1 = sin(45); ... asin1 = asin(276); ...
... if(abs(decline) > 30) ...
... c = ceil(45.6); f = floor(13.3); ...
An example of its usage might be:
... triggerFrame = random(20,50); ...
... rad = 0.05 * maxlen * (1 + randu()) ...
... t = min(top,7); ...
... t = mod(34.5,6); // returns 4.5 ...or, alternately,
... t = 34.5 % 6; ...
... t = pow(5,3); // returns 125 ...
... t = hypot(3,5); ...
... t = rad(degrees); // equivalent to: degrees * (PI / 180) ...
... if(range(top,3,8)) ...
... t = selector(4,7,15,3); // returns 15 ... t = selector(15,7,7,10); // returns 10 ...
... t += step(y,10,.25); // step by .25 ...
... t = round(37.7,0); // returns 38 t = round(4.4394,2); // returns 4.44 ...
... t = frac(46.75); // returns 0.75 ...
... t = fac(5); // returns 120 ...
... t = vmag(x,y,z); // calculate magnitude of my location ...
... error("Value ",val," exceeds max limit of ", 10 * items," items"); ...
... sceneFile = File("/temp.lws","w"); ...File open modes are identical to those provided by C. They are:
r read (ascii) w write (ascii) a append (ascii) b binary (i.e., "rb" would be read-binary) + with update (i.e., the file pointer can be moved arbitrarily)For instance, to open a file for random binary read access, you would specify "rb+" as the open mode for your file.
If the optional open mode value is not specified, then the file will be opened in read-ascii ("r") mode by default.
In this example, we employ LScript's string math feature to build the final filename.
index = 9; ... if(fileexist("/temp" + index + ".lwo")) // filename becomes "/temp9.lwo" ...
index = 1; ... if(filedelete("\\temp",index,".lwo")) error("Cannot remove file \\temp",index,".lwo!); ...
center() returns a vector data type.
// since boundingbox() returns two vectors, we // can just feed its output to center() objectCntr = center(boundingbox());
extent() returns a vector data type, whose elements (x,y,z) represent the extents along each of those axes.
objectSize = extent(boundingbox());
str = "23,45,69.6,100"; tokens = parse(",",str); // returns "23", "45", "69.9" // and "100" ...
str = "23,45,69.6,100"; tokens[10] = nil; t = size(tokens); // returns 0 tokens = parse(",",str); // returns four elements t = size(tokens); // returns 4 tokens[8] = 1.0; t = size(tokens); // returns 5 ...
These functions will extract values from a character string, even if the numeric values do not appear that the beginning of the string.
str = "69.6"; t = number(str); // returns 69.9 t = integer(str); // returns 69 t = integer(round(number("69.9"))); // returns 70 t = number("The answer is: .1593"); // returns .1593 ...
str = "4 6.5 8"; t = vector(str); // returns <4,6.5,8> ...
t = string("Value ",val," exceeds max limit of ", 10 * items," items");
file = getfile("Select A Scene...","*.lws"); if(file == nil) return; if(fileexists(file)) { base = split(file); // get the components (base becomes an array) ...Components of the string that do not exist (i.e., no drive designation) will be returned as nil.
Arrays can also be appended to other arrays using this function.
However, if the asyncspawn pragma directive has been declared in the script, then the spawn() command will, upon success, return the process id of the external process it launched. This process id is required as an argument to the other process control functions wait() and terminate().
// launch ScreamerNet II in parallel snID = spawn("lwsn -2 ", getenv("TMP"),"\\snii.job ", getenv("TMP"),"\\snii.rpl"); if(snID == nil) { error("Cannot create ScreamerNet process"); ...
terminate(snID); // shut down ScreamerNet
tempfile = getenv("TMP") + "/33j4ks.$$$";
"Fonts"/FONTSDIR Modeler "Macros"/MACROSDIR Modeler "Install"/INSTALLDIR Layout/Modeler (LightWave Installation Directory) "Objects"/OBJECTSDIR Layout/Modeler "Images"/IMAGESDIR Layout/Modeler "Motions"/MOTIONSDIR Layout/Modeler "Temp"/TEMPDIR Layout/Modeler "Plugins"/PLUGINSDIR Layout/Modeler "Settings"/SETTINSDIR Layout/Modeler (Location of alternate configurations) "Content"/CONTENTDIR Layout "Scenes"/SCENESDIR Layout "Hierarchies"/HIERARCHIESDIR Layout "Surfaces"/SURFACESDIR Layout "Output"/OUTPUTDIR Layout "Animations"/ANIMATIONSDIR Layout "Envelopes"/ENVELOPESDIR Layout "Previews"/PREVIEWSDIR Layout "Command"/COMMANDDIR LayoutYou might retrieve one of these directory values in the following fashion:
... install = getdir("Install"); ... plugins = getdir(PLUGINSDIR); ...
For the purposes of conversion, 1000 milliseconds is equal to 1 second.
sleep(1000); // sleep for 1 second
dump("/myscript.var");The dump() command is not supported in the run-time environment. Scripts containing this command will not compile successfully with the BMC Script Compiler.
The store() command takes two parameters. The first parameter is a string literal (or variable with a character string) that uniquely identifies the value to be stored. The second parameter is the actual value itself.
recall() retrieves values that have been previously store()'d. As with store(), it too takes two parameters. The first, like store(), is the value identifier that was originally used to retain the value. Unlike store(), however, the second parameter is a default value to return if a store() has never been issued for that identifier.
The following LScript illustrates the uses of these two commands. When executed more than once, the values stored will change.
main { heading = recall("heading",15); testing = recall("testing",95.34); myName = recall("myName","Bob Hood"); newName = recall("newName", string(myName," has no life!")); info("got heading == ",heading, ", testing == ",testing); info("got myName == ",myName, ", newName == ",newName); store("heading",++heading); store("testing",testing + .5); store("myName",myName); store("newName",newName); }
strleft() and strright() return a portion of a character string beginning from the indicated direction. They both accept two parameters, where the first is the character string to be processed, and the second is a numeric count of the number of characters to extract.
// the following prints 'My first name is "Ted"' info("My first name is \"", strleft("Ted Philmore",3"),"\");strsub() is another extraction function. However, this function allows you to extract an arbitrary number of characters from within the string starting from an arbitrary location, instead of starting from one of its ends.
t = strsub("Ted Philmore",3,3); // returns "d P"As their names imply, strupper() and strlower() return a copy of the provided string as either all upper- or lower-case characters, respectively.
In all cases, the original string provided is not modified.